package com.fenghongzhang.day012;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //其实就是代码加一个意图过滤器
//        MyReceiver2 myReceiver2 = new MyReceiver2();
//        IntentFilter intentFilter = new IntentFilter();
//        intentFilter.addAction("com.feng");
//        registerReceiver(myReceiver2,intentFilter);
    }


    //发送广播
    public void send(View view) {

        Intent intent = new Intent();
        //设置你的频道
        intent.setAction("com.feng");
        //设置内容
        intent.putExtra("name","小明1");

//        Bundle bundle = new Bundle();
//        bundle.putString("name","小明");
//        intent.putExtras(bundle);
        sendBroadcast(intent);

//
//        Intent intent1 = new Intent();
//        //设置你的频道
//        intent1.setAction("com.feng1");
//        //设置内容
//        intent1.putExtra("name1","小明1");
//
////        Bundle bundle = new Bundle();
////        bundle.putString("name","小明");
////        intent.putExtras(bundle);
//        sendBroadcast(intent1);

    }

    public void sendOrder(View view) {

        Intent intent = new Intent();
        //设置你的频道
        intent.setAction("com.feng1");
        //设置内容
        intent.putExtra("name","小明111");

//        Bundle bundle = new Bundle();
//        bundle.putString("name","小明");
//        intent.putExtras(bundle);
        //发送一个有序广播
//        sendOrderedBroadcast(intent,null);
        sendBroadcast(intent);
    }
}
